package com.ruoyi.project.AnswerQuestion.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.project.AnswerQuestion.domain.TbQuestion;
import com.ruoyi.project.AnswerQuestion.mapper.TbQuestionMapper;
import com.ruoyi.project.AnswerQuestion.service.ITbQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 实验答疑，提问Service业务层处理
 * 
 * @author lvyongwei
 * @date 2020-11-26
 */
@Service
public class TbQuestoinServiceImpl implements ITbQuestionService
{
    @Autowired
    private TbQuestionMapper tbQuestionMapper;

    /**
     * 查询实验答疑，提问
     * 
     * @param answerId 实验答疑，提问ID
     * @return 实验答疑，提问
     */
    @Override
    public TbQuestion selectTbQuestionById(Long answerId)
    {
        return tbQuestionMapper.selectTbQuestionById(answerId);
    }

    /**
     * 查询实验答疑，提问列表
     * 
     * @param tbAnswer 实验答疑，提问
     * @return 实验答疑，提问
     */
    @Override
    public List<TbQuestion> selectTbQuestionList(TbQuestion tbAnswer)
    {
        return tbQuestionMapper.selectTbQuestionList(tbAnswer);
    }

    /**
     * 新增实验答疑，提问
     * 
     * @param tbAnswer 实验答疑，提问
     * @return 结果
     */
    @Override
    public int insertTbQuestion(TbQuestion tbAnswer)
    {
        tbAnswer.setCreateTime(DateUtils.getNowDate());
        return tbQuestionMapper.insertTbQuestion(tbAnswer);
    }

    /**
     * 修改实验答疑，提问
     * 
     * @param tbAnswer 实验答疑，提问
     * @return 结果
     */
    @Override
    public int updateTbQuestion(TbQuestion tbAnswer)
    {
        tbAnswer.setUpdateTime(DateUtils.getNowDate());
        return tbQuestionMapper.updateTbQuestion(tbAnswer);
    }

    /**
     * 删除实验答疑，提问对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteTbQuestionByIds(String ids)
    {
        return tbQuestionMapper.deleteTbQuestionByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除实验答疑，提问信息
     * 
     * @param answerId 实验答疑，提问ID
     * @return 结果
     */
    @Override
    public int deleteTbQuestionById(Long answerId)
    {
        return tbQuestionMapper.deleteTbQuestionById(answerId);
    }
}
